1. Technology Field
The present invention relates to a command executing method. Particularly, the present invention relates to a command executing method of executing a plurality of write commands received from a host system, a memory controller and the memory storage apparatus using the same.
2. Description of Related Art
Digital cameras, cell phones, and MP3 players have undergone rapid growth in recent years, so that consumer demands for storage media have also rapidly increased. A rewritable non-volatile memory is one of the most adaptable memories for electronic products (for example, notebook computers) due to its characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure, and high read-and-write speed. A solid state drive (SSD) is a storage apparatus which uses a flash memory as its storage medium. Thus, in recent years, the flash memory industry has become a major part of the electronic industry.
The rewritable non-volatile memory has a plurality of physical blocks, and each physical block has a plurality of physical pages, where when data is written into the physical block, it has to be sequentially written according to a sequence of the physical pages. Moreover, the physical pages written with data have to be erased first for again writing data thereon. Particularly, the physical block is the smallest unit that can be erased, and the physical page is the smallest unit that can be programmed. Therefore, in management of the rewritable non-volatile memory, the physical blocks are at least grouped into a data area and a spare area.
The physical blocks of the data area (which are also referred to as data physical blocks) have used for storing data stored by a host system. In detail, a memory management circuit converts a logical access address accessed by the host system into a logical page of a logical block, and maps the logical page of the logical block to a physical page of a physical block of the data area. Namely, in management of the rewritable non-volatile memory module, the physical blocks of the data area are regarded as used physical blocks (for example, stored with data written by the host system). For example, the memory management circuit may use a logical block-physical block mapping table to record a mapping relationship between the logical blocks and the physical blocks of the data area, wherein the logical pages of the logical block sequentially correspond to the physical pages of the mapped physical block.
The physical blocks of the spare area are used to substitute the physical blocks of the data area. In detail, as described above, the physical block written with data has to be erased first for again writing data thereon, so that the physical blocks of the spare area are designed to be written with updated data to substitute the physical blocks originally mapped to the logical blocks. Therefore, the physical blocks in the spare area are empty or available physical blocks, i.e. physical blocks that are not stored with data or physical blocks stored with data marked to be invalid.
Namely, the physical pages of the physical blocks of the data area and the spare area are used to map the logical pages of the logical blocks in an alternating manner, so as to store the data written by the host system.
For example, when the logical access address to be written with updated data by the host system corresponds to a certain logical page of a certain logical block of the storage apparatus, the memory management circuit of the storage apparatus selects one physical block from the spare area, and writes the updated data into physical pages of the selected physical block. Then, when the physical blocks of the spare area are exhausted, the memory management circuit performs a data merging operation to the logical block. For example, in the data merging operation, the memory management circuit selects a physical block from the spare area to serve as a new data physical block, and writes all updated and valid data belonging to the logical block into the new data physical block, and re-maps the logical block to the new data physical block.
To effectively improve the accessing performance, the memory storage apparatus is generally configured with a buffer memory. For example, when a write command and data to be written are received from the host system, the memory management circuit temporarily stores the data to be written and related information (for example, the logical page where the write data belongs to) into the buffer memory, and sends a response message to the host system to notify that the write command is completed, so as to shorten a response time. Then, when the buffer memory is full, the data in the buffer memory is written into the rewritable non-volatile memory module, so as to empty the storage space of the buffer memory to store a next batch of write data.
However, in case that the buffer memory is full and the physical blocks of the spare area are to be exhausted, if the write command is received from the host system, the memory management circuit has to complete the data merging operation in order to execute the write command. Since the data merging operation is time-consuming, compared to executions of other access commands, the host system has to wait a rather long time to receive the response message notifying that the write command is completed from the memory storage apparatus. During such process, a user of the host system may mistake that the memory storage apparatus is down or perceive that the memory storage apparatus is unstable. Therefore, in case that the buffer memory is written full and the physical blocks of the spare area are to be exhausted, how to shorten the time for the host system receiving the response message is an important issue.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.